<!-- 修改仓库 -->
<template>
  <div class="my-invoice-detail">  
    <row title="仓库名称" >
        <input class="ipt" type="text" slot="rowRight" placeholder="请输入仓库名称" v-model="name">
    </row>
    <group>
        <x-address  title="所在区域"
                    :value="value"
                    :raw-value="true" 
                    :list="addressData"  
                    @on-shadow-change="getValue"
                    placeholder="请选择地址">
        </x-address>
    </group>
    
    <row title="仓库地址">
        <input class="ipt" type="text" slot="rowRight" placeholder="请输入仓库地址" v-model="shopAdress">
    </row>
    <row title="联系人">
        <input class="ipt" type="text" slot="rowRight" placeholder="请输入联系人" v-model="cancat">
    </row>
    <row title="联系电话" >
        <input class="ipt" type="number" slot="rowRight" placeholder="请输入联系电话" v-model="cancatPhone">
    </row> 
    <div class="height120"></div>
    <div class="btn isbtn" @click="submit()">提交</div>
  </div>
</template>

<script>
import row from '@/components/row'
import api from '@/api/api.js' 
import { XAddress,Group,ChinaAddressV4Data } from 'vux'
import { Message } from 'element-ui'
export default { 
  components: {
    row, 
    Group,
    XAddress
  },
  data () {
    return {
      value:[],
      addressData: ChinaAddressV4Data,
      name:'',
      shopAdress:'',
      cancat:'',
      cancatPhone:'',
      chooseIdx:'', 
      detail:{}
    }
  },
  mounted () {
      this.getDetail();
  },
  filters: {
     
  },
  methods: {
    // 获取详情
    getDetail(id){
         const detail = this.$store.state.warehouseDetail;
        this.detail=detail; 
        this.name=detail.name;
        this.cancat=detail.contacts;
        this.cancatPhone=detail.telephone;
        this.value=[detail.province,detail.city,detail.district];
        console.log(this.value);
        this.shopAdress=detail.address; 
    },
    getValue(ids,names) {
        this.value =names;
    },
    submit(){
        if(!this.name){
            return  Message({
                message: "请输入仓库名！",
                type: 'error',
                duration: 1 * 1000
            })
        }
        if(!this.value[0]){
            return  Message({
                message: "请选择区域",
                type: 'error',
                duration: 1 * 1000
            })
        }
        if(!this.shopAdress){
            return  Message({
                message: "请填写地址",
                type: 'error',
                duration: 1 * 1000
            })
        }
        api.warehouseMng.warehouseUpdate({
            replWarehouseId:this.detail.id,
            "name":this.name,
            "contacts":this.cancat,
            "telephone":this.cancatPhone,
            "province":this.value[0],
            "city":this.value[1],
            "district":this.value[2],
            "address":this.shopAdress
        },res=>{
            this.$router.go(-2);
            return  Message({
                message: "更新成功",
                type: 'success',
                duration: 1 * 1000
            })

        })
    }, 
  }
}
</script>
<style lang="less" scoped>
/deep/.vux-no-group-title{
    margin-top: 0;
}
/deep/.weui-cells:before{
    display: none;
}
/deep/.weui-cells::after{
    left: 20px;
}
.wrap-box{
    display: flex;
    flex-wrap: wrap;
    .warp-img{
        width: 80px;
        height: 80px;
    }
    .iconguanbi{
        color: #fbfbfb;
        background: rgba(33,33,33,.7);
        font-size: .36rem;
        top: 2px;
        right: 12px;
        position: absolute;
    }
}
.warp-img-box{
    position: relative;
}
.uploader-box{
    width: 100px;
    height: 100px;
}
.invoice-photo{
    padding: 12px 16px;
}
.map-title{
    height: 40px;
    line-height: 40px;
    font-size: 16px;
    font-weight: bold;
}
.invoice-photo-img{
   width: 100%;
   min-width: 74px;
   min-height: 74px; 
}
input {
    outline: none;
}
.ipt{
    border: none;
}
.invoice-order{
    display: flex;
    height: 40px;
    line-height: 40px;

}
.invoice-number{
    color: #444;
    width: 35%;
    padding-left: 8px;
}
.tips{
    color: #999;
    font-size: 11px;
    margin-left: 8px;
}
.invoice-money{
    color: #999;
    width: 30%;
}
.invoice-timer{
   color: #666; 
   width: 35%;
}
.invoice-active{
    background: #e1e1e1;
}

.wrap-box{
    display: flex;
    flex-wrap: wrap;
    img{
        margin-bottom: 10px;
        margin-right: 10px;
        width: 74px;
        height: 74px;    
    }
}
.height120{
    height: 60px;
}
.btn{
    text-align: center;
    line-height: 50px;
    background: #FABE00;
    color: #fff;
    height: 50px;
    font-size: 16px;
    letter-spacing: 4px;
    position: fixed;
    width: 100%;
    bottom: 0;
    left: 0;
}
.add-img {
    width: 100%;
    padding: 10px;
}

.add-img p {
    color: #999;
}
.add-image {
    padding-top: 15px; 
    width: 80px; 
    height: 80px;
    border: 1px dashed rgba(0, 0, 0, .2);
}

.add-image .iconxiangji {
    font-size: 24px;
}
</style>
